[SPARK-17013][SQL] Parse negative numeric literals#14608
[SPARK-17013][SQL] Parse negative numeric literals#14608petermaxlee wants to merge 3 commits intoapache:masterfrom
Conversation
|
Test build #63634 has finished for PR 14608 at commit
|
|
I found the SQL generation for expression pretty weird with parentheses. The current design adds parentheses at the outside of each expression. For example, "1+2" becomes "(1+2)". There was this subtle bug in UnaryMinus for negative numeric literal, as the generated SQL becomes "--number", which is a comment in SQL. I fixed it here by injecting a space. It might be better to change these to put parentheses in the inside, e.g. @cloud-fan, @hvanhovell, @liancheng what do you think? |
|
Test build #63644 has finished for PR 14608 at commit
|
|
adding a space LGTM. I think |
|
Test build #63652 has finished for PR 14608 at commit
|
|
LGTM |
|
Shouldn't we wrap literals with () to be safe? |
|
I'm going to merge this one in master/2.0. |
## What changes were proposed in this pull request? This patch updates the SQL parser to parse negative numeric literals as numeric literals, instead of unary minus of positive literals. This allows the parser to parse the minimal value for each data type, e.g. "-32768S". ## How was this patch tested? Updated test cases. Author: petermaxlee <petermaxlee@gmail.com> Closes #14608 from petermaxlee/SPARK-17013. (cherry picked from commit 00e103a) Signed-off-by: Reynold Xin <rxin@databricks.com>
What changes were proposed in this pull request?
This patch updates the SQL parser to parse negative numeric literals as numeric literals, instead of unary minus of positive literals.
This allows the parser to parse the minimal value for each data type, e.g. "-32768S".
How was this patch tested?
Updated test cases.